stage.set_axis(8)
stage.create_grid_overlay(1, "black")
x_label = codesters.Text("x", 7.5, -.5)
x_label.set_size(.8)
y_label = codesters.Text("y", .3, 7.5)
y_label.set_size(.8)
def arrow(axis, scale, color):
if axis == "x":
top1 = codesters.Line(scale, 0, scale - .3, .5, color)
bottom1 = codesters.Line(scale, 0, scale - .3, -.5, color)
top2 = codesters.Line(-scale, 0, -scale + .3, .5, color)
bottom2 = codesters.Line(-scale, 0, -scale + .3, -.5, color)
if axis == "y":
top1 = codesters.Line(0, scale, .5, scale -.3, color)
bottom1 = codesters.Line(0, scale, -.5, scale-.3, color)
top2 = codesters.Line(0, -scale, .5, -scale +.3, color)
bottom2 = codesters.Line(0, -scale, -.5 , -scale + .3, color)
arrow("x", 8, "black")
arrow("y", 8, "black")
def wrong():
rect_text.set_text("Read the directions above.")
x_highlight = codesters.Rectangle(0, 0, 16, .2, "yellow")
y_highlight = codesters.Rectangle(0, 0, .2, 16, "yellow")
x_highlight.hide()
y_highlight.hide()
origin_marker = codesters.Circle(0, 0, .5, None, "blue")
origin_label = codesters.Text("origin", 1, .5, "grey")
x_axis = codesters.Text("x-axis", 6, -1, "green")
y_axis = codesters.Text("y-axis ", 2, 7.5, "green")
nar_rect = codesters.Rectangle(-4.25, 7, 7.5, 2.25, "lightgreen")
nar = codesters.Text("Points on an axis", -4.25, 7)
click_rect = codesters.Rectangle(-5.5, -7.5, 5, 1, "lightblue")
rect_text = codesters.Text("Click to continue", -5.5, -7.5, "black")
point1 = codesters.Circle(3, 0, .5, "green")
point2 = codesters.Circle(5, 0, .5, "purple")
point3 = codesters.Circle(-2, 0, .5, "blue")
point4 = codesters.Circle(-6, 0, .5, "orange")
point5 = codesters.Circle(0, -5, .5, "red")
point5.hide()
points = [point1, point2, point3, point4]
for i in points:
i.hide()
def click_1():
origin_label.hide()
rect_text.set_text(" ")
x_highlight.show()
nar.set_text("Any point on the x axis \nhas a y-coordinate of 0.")
nar.set_y(nar.get_y() + .5)
for i in points:
i.show()
x_val = i.get_x()
y_val= i.get_y()
i.say('('+ str(x_val) + " , " + str(y_val)+ ")")
rect_text.set_text("Click to continue.")
stage.wait(.2)
click_rect.event_click(click_2)
def click_2():
for i in points:
i.hide()
stage.wait(.2)
rect_text.set_text(" ")
nar.set_text("Any point on the y-axis \n has an x-coordinate of 0.")
x_highlight.hide()
y_highlight.show()
lists = []
for i in points:
new_x = i.get_y()
new_y = i.get_x()
lists.append([new_x, new_y])
i.go_to(new_x, new_y)
i.say('('+ str(new_x) + " , " + str(new_y)+ ") ")
i.show()
rect_text.set_text("Click to continue.")
click_rect.event_click(click_3)
def click_3():
y_highlight.hide()
rect_text.set_text(" ")
click_rect.hide()
for i in points:
i.hide()
i.say(' ')
i.set_width(.8)
i.set_height(.8)
point5.set_width(.8)
point5.set_height(.8)
point1.go_to(-4, 0)
point1.show()
point1.set_opacity(.01)
nar.set_text("Start at the origin and \n count 4 spaces left to \n get to (-4, 0)")
point1.event_click(click_4)
def click_4():
rect_text.set_text(' ')
point1.set_opacity(1)
point1.say("(" + str(point1.get_x()) + ',' + str(point1.get_y()) + ")")
nar.set_text("Great! Now find (5, 0) \n and click on it!")
point2.go_to(5, 0)
point2.set_opacity(.01)
point2.show()
point2.event_click(click_5)
def click_5():
point2.set_opacity(1)
point2.say("(" + str(point2.get_x()) + "," + str(point2.get_y())+ ")")
nar.set_text("Great job! \n Now find point (-2, 0) \nand click on it!")
stage.wait(.5)
point3.go_to(-2,0)
point3.set_opacity(.01)
point3.show()
point3.event_click(click_6)
def click_6():
point3.set_opacity(1)
point3.say("(" + str(point3.get_x()) + "," + str(point3.get_y())+ ")")
nar.set_text("Great job! Now let's try \n some points on the y-axis! \n Click on (0, 4).")
stage.wait(.5)
point4.go_to(0, 4)
point4.set_opacity(.01)
point4.show()
point4.event_click(click_7)
def click_7():
point4.set_opacity(1)
point4.say(" (" + str(point4.get_x()) + "," + str(point4.get_y())+ ")")
nar.set_text("Great job! \n Now click on (0, -5)!")
stage.wait(.5)
point5.set_opacity(.01)
point5.show()
point5.event_click(click_8)
def click_8():
point5.set_opacity(1)
point5.say(" (" + str(point5.get_x()) + "," + str(point5.get_y())+ ")")
nar.set_text("Great job! \n Click Submit \n and Next to continue!")
stage.wait(.5)
click_rect.event_click(click_1)